package com.example.logistics_oa.controller;

import com.example.comment_oa.pojos.xinzi.*;
import com.example.comment_oa.response.AjaxResponse;
import com.example.logistics_oa.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/logisticsOa")
@CrossOrigin
public class JiBenGeRenController {
    @Autowired
    ShsalaryZhubiaoService shsalaryZhubiaoService;

    @Autowired
    JibenXinzijisuanService jibenXinzijisuanService;

    @Autowired
    JibenQitajineService jibenQitajineService;
    @Autowired
    JibenButiejisuanService jibenButiejisuanService;
    @Autowired
    JibenKaoqinhesuanService jibenKaoqinhesuanService;

    @Autowired
    JibenGongzidanService jibenGongzidanService;

    @PostMapping("/chajibenxinzi/{jibenGonghao}")
    public AjaxResponse chajibenxinzi(@PathVariable("jibenGonghao") String jibenGonghao){
        List<ShsalaryZhubiao> shsalaryZhubiaos = shsalaryZhubiaoService.selectDiYiTiao();

        List<JibenXinzijisuan> jibenXinzijisuans = jibenXinzijisuanService.selectOnePerson(shsalaryZhubiaos.get(0).getSrId(), jibenGonghao);
//        System.err.println(shsalaryZhubiaos.get(0).getSrId()+"???");
//        System.err.println(jibenGonghao);
//        System.err.println(jibenXinzijisuans);
        return AjaxResponse.success(jibenXinzijisuans);
    }


    @PostMapping("/cahqitagerende/{jibenGonghao}")
    public AjaxResponse chaqitajine(@PathVariable("jibenGonghao") String jibenGonghao){
        List<ShsalaryZhubiao> shsalaryZhubiaos = shsalaryZhubiaoService.selectDiYiTiao();
        List<JibenQitajine> jibenQitajines = jibenQitajineService.selectOnePerson22(shsalaryZhubiaos.get(0).getSrId(), jibenGonghao);
        return AjaxResponse.success(jibenQitajines);
    }



    @PostMapping("/selectbutieOnepersonde/{jibenGonghao}")
    public AjaxResponse selectbutieOnepersonde(@PathVariable("jibenGonghao") String jibenGonghao){
        List<ShsalaryZhubiao> shsalaryZhubiaos = shsalaryZhubiaoService.selectDiYiTiao();
        List<JibenButiejisuan> jibenButiejisuans = jibenButiejisuanService.selectbutieOnepersonde(shsalaryZhubiaos.get(0).getSrId(), jibenGonghao);
        return AjaxResponse.success(jibenButiejisuans);
    }

    @PostMapping("/selectOnePersonKaoQin/{jibenGonghao}")
    public AjaxResponse selectOnePersonKaoQin(@PathVariable("jibenGonghao") String jibenGonghao){
        List<ShsalaryZhubiao> shsalaryZhubiaos = shsalaryZhubiaoService.selectDiYiTiao();
        List<JibenKaoqinhesuan> jibenKaoqinhesuans = jibenKaoqinhesuanService.selectOnePerson(shsalaryZhubiaos.get(0).getSrId(), jibenGonghao);
        return AjaxResponse.success(jibenKaoqinhesuans);
    }

    @PostMapping("/selectOnePersonGongDegongzidan/{jibenGonghao}")
    public AjaxResponse selectOnePersonGongDe(@PathVariable("jibenGonghao") String jibenGonghao){
        List<ShsalaryZhubiao> shsalaryZhubiaos = shsalaryZhubiaoService.selectDiYiTiao();
        List<JibenGongzidan> jibenGongzidans = jibenGongzidanService.selectOnePersonGongDe(shsalaryZhubiaos.get(0).getSrId(), jibenGonghao);
        return AjaxResponse.success(jibenGongzidans);
    }






}
